package gob.osinerg.emergencia.tag;

import org.apache.commons.lang.StringUtils;



public class TextAreaControl extends GenericControl {
	
	private String OPEN_TAG="<textArea";
	private String CLOSE_TAG="</textArea>";
	
	private int rows;
	private int cols;

	
	
	public int getRows() {
		return rows;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}
	



	public int getCols() {
		return cols;
	}

	public void setCols(int cols) {
		this.cols = cols;
	}

	public String toString() {
		
		StringBuffer sb = new StringBuffer();
		sb.append("<td width=\"25%\">");
		sb.append(StringUtils.isEmpty(getLabel())?"":getLabel());
		sb.append("</td>");
		sb.append("<td>");
		sb.append(OPEN_TAG);
		addElements(sb, "name", getName());
		addElements(sb, "rows", ""+getRows());
		addElements(sb, "cols", ""+getCols());
		addElements(sb, "onKeyDown", "javascript:if (this.value.length > 2000) {this.value = this.value.substring(0, 2000);}");
		addElements(sb, "onKeyUp", "javascript:if (this.value.length > 2000) {this.value = this.value.substring(0, 2000);}");
		sb.append(">");
		sb.append(StringUtils.isEmpty(getValue())?"":getValue());
		sb.append(CLOSE_TAG);
		sb.append(StringUtils.isEmpty(getRequired())?"":"(*)");
		sb.append("</td>");
		return sb.toString();
	}
	

}
